#pragma once
#include "atlbase.h"


template <class T>
class Singleton
{
protected:
	static CAutoPtr<T> Instance;

protected:
	Singleton( const Singleton& Src);
	Singleton& operator=( const Singleton& Src);
	Singleton(){ }


public:	
	~Singleton()
	{
// 		if(Instance)
// 			delete Instance;
// 		Instance = 0;
	}

	static T& GetInstance()
	{
		if(!Instance)
			Instance.Attach(new T());
		return (*Instance);
	}
};

template <class T> CAutoPtr<T> Singleton<T>::Instance;
